﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using DoAnOOP.BussinessLayer;

namespace DoAnOOP
{
    public partial class frmLogIn : DevComponents.DotNetBar.Office2007Form
    {
        private frmMain myMain;
        public frmLogIn(frmMain _main)
        {
            InitializeComponent();
            myMain = _main;
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        clsBusUserLogin clsMyBusUserLogin;

        private void btnDangnhap_Click(object sender, EventArgs e)
        {
            clsBusUserLogin clsMyBusUserLogin = new clsBusUserLogin();
            if (clsMyBusUserLogin.checkLogin(txtid.Text, txtpass.Text))
            {
                frmMain.mssv = clsBusUserLogin.username;
                frmMain.password = clsBusUserLogin.password;
                frmMain.QuyenHan = clsBusUserLogin.QuyenHan;

                MessageBox.Show("Chào mừng " + frmMain.mssv + " đã đăng nhập thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                myMain.setQuyenHan();
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("Tên đăng nhập hay mật khẩu sai");
                txtid.Focus();
            }
        }

        private void frmLogIn_Load(object sender, EventArgs e)
        {
            clsMyBusUserLogin = new clsBusUserLogin();
            //styleManager1.ManagerStyle = eStyle.Office2010Blue;
        }

        //private void txtid_KeyPress(object sender, KeyPressEventArgs e)
        //{
        //    if (e.KeyChar == 13)
        //    {
        //        btnDangnhap_Click(sender, e);
        //    }
        //}

        private void txtpass_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                btnDangnhap_Click(sender, e);
            }
        }

        
    }
}